import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import UserLogin from "@/views/UserLogin.vue";

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    redirect:'/index',
    children:[
      {
        path: '/abnormal',
        name: 'abnormal',  // 对应 AbnormalRecordListView.vue
        component: () => import('../views/abnormal/AbnormalRecordListView.vue')
      },
      {
        path: '/abnormal/process',
        name: 'abnormalProcess',  // 对应 AbnormalRecordDetailView.vue (修复文件名)
        component: () => import('../views/abnormal/AbnormalRecordDetailView.vue')
      },
      {
        path:'/index',
        name: 'index',
        component: () => import('../views/index/IndexView.vue')
      },
      {
        path: '/announcement',
        name: 'announcement',
        component: () => import('../views/announcements/AnnouncementView.vue')
      },
      {
        path: '/announcementAdd',
        name: 'announcementAdd',
        component:() => import('../views/announcements/AnnouncementAddView.vue')
      },
      {
        path: '/feedback',
        name: 'feedback',
        component: () => import('../views/feedbacks/FeedBackView.vue')
      },
      {
        path: '/feedback/process',
        name: 'feedbackProcess',
        component: () => import('../views/feedbacks/FeedbackProcess.vue')
      },
      {
        path: '/order',
        name: 'order',
        component: () => import('../views/orders/OrderView.vue')
      },
      {
        path: '/product',
        name: 'product',
        component:() => import('../views/products/ProductView.vue')
      },
      {
        path: '/product/add',
        name: 'productAdd',
        component:() => import('../views/products/ProductAdd.vue')
      },
      {
        path: '/report',
        name: 'report',
        component:() => import('../views/reports/ReportView.vue')
      },
      {
        path: '/reportUpdate',
        name: 'reportUpdate',
        component:() => import('../views/reports/ReportUpdateView.vue')
      },
      {
        path: '/user',
        name: 'user',
        component:() => import('../views/user/UserView.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'adminLogin',
    component: UserLogin
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
